#include <windows.h>
#include<wincon.h>


void color_console(WORD text_color, WORD bg_color)
{
    HANDLE console_h=GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(console_h, text_color|bg_color*16);
}

void change_cursor(unsigned size, unsigned visibility)
{
    HANDLE console_h;
    CONSOLE_CURSOR_INFO cci;
    console_h=GetStdHandle(STD_OUTPUT_HANDLE);
    cci.dwSize=size;
    cci.bVisible=visibility;
    SetConsoleCursorInfo(console_h, &cci);
}

void move_cursor(unsigned x, unsigned y)
{
    HANDLE console_h;
    COORD position;
    console_h=GetStdHandle(STD_OUTPUT_HANDLE);
    position.X=x;
    position.Y=y;
    SetConsoleCursorPosition(console_h, position);
}

int cursor_x()
{
    HANDLE console_h;
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    console_h=GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(console_h, &csbi);
    return csbi.dwCursorPosition.X;
}

int cursor_y()
{
    HANDLE console_h;
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    console_h=GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(console_h, &csbi);
    return csbi.dwCursorPosition.Y;
}

